<!DOCTYPE html>
<html lang=zh>
<head>
    <meta charset="utf-8">
    
    <title>程序猿</title>
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1" />
    <meta property="og:type" content="website">
<meta property="og:title" content="程序猿">
<meta property="og:url" content="http://yoursite.com/page/2/index.html">
<meta property="og:site_name" content="程序猿">
<meta name="twitter:card" content="summary">
<meta name="twitter:title" content="程序猿">
    

    
        <link rel="alternate" href="/" title="程序猿" type="application/atom+xml" />
    

    

    <link rel="stylesheet" href="/libs/font-awesome/css/font-awesome.min.css">
    <link rel="stylesheet" href="/libs/open-sans/styles.css">
    <link rel="stylesheet" href="/libs/source-code-pro/styles.css">

    <link rel="stylesheet" href="/css/style.css">

    <script src="/libs/jquery/2.1.3/jquery.min.js"></script>
    
    
        <link rel="stylesheet" href="/libs/lightgallery/css/lightgallery.min.css">
    
    
        <link rel="stylesheet" href="/libs/justified-gallery/justifiedGallery.min.css">
    
    
    
    


</head>

<body>
    <div id="container">
        <header id="header">
    <div id="header-main" class="header-inner">
        <div class="outer">
            <a href="/" id="logo">
                <i class="logo"></i>
                <span class="site-title">程序猿</span>
            </a>
            <nav id="main-nav">
                
                    <a class="main-nav-link" href="http://chinesszz.oschina.io/">主页</a>
                
                    <a class="main-nav-link" href="/archives">档案</a>
                
                    <a class="main-nav-link" href="/archives">分类</a>
                
                    <a class="main-nav-link" href="/archives">标签</a>
                
                    <a class="main-nav-link" href="/关于我">关于我</a>
                
            </nav>
            
                
                <nav id="sub-nav">
                    <div class="profile" id="profile-nav">
                        <a id="profile-anchor" href="javascript:;">
                            <img class="avatar" src="/css/images/avatar.png" />
                            <i class="fa fa-caret-down"></i>
                        </a>
                    </div>
                </nav>
            
            <div id="search-form-wrap">

    <form class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="搜索" />
        <button type="submit" class="search-form-submit"></button>
    </form>
    <div class="ins-search">
    <div class="ins-search-mask"></div>
    <div class="ins-search-container">
        <div class="ins-input-wrapper">
            <input type="text" class="ins-search-input" placeholder="想要查找什么..." />
            <span class="ins-close ins-selectable"><i class="fa fa-times-circle"></i></span>
        </div>
        <div class="ins-section-wrapper">
            <div class="ins-section-container"></div>
        </div>
    </div>
</div>
<script>
(function (window) {
    var INSIGHT_CONFIG = {
        TRANSLATION: {
            POSTS: '文章',
            PAGES: '页面',
            CATEGORIES: '分类',
            TAGS: '标签',
            UNTITLED: '(未命名)',
        },
        ROOT_URL: '/',
        CONTENT_URL: '/content.json',
    };
    window.INSIGHT_CONFIG = INSIGHT_CONFIG;
})(window);
</script>
<script src="/js/insight.js"></script>

</div>
        </div>
    </div>
    <div id="main-nav-mobile" class="header-sub header-inner">
        <table class="menu outer">
            <tr>
                
                    <td><a class="main-nav-link" href="http://chinesszz.oschina.io/">主页</a></td>
                
                    <td><a class="main-nav-link" href="/archives">档案</a></td>
                
                    <td><a class="main-nav-link" href="/archives">分类</a></td>
                
                    <td><a class="main-nav-link" href="/archives">标签</a></td>
                
                    <td><a class="main-nav-link" href="/关于我">关于我</a></td>
                
                <td>
                    
    <div class="search-form">
        <input type="text" class="ins-search-input search-form-input" placeholder="搜索" />
    </div>

                </td>
            </tr>
        </table>
    </div>
</header>

        <div class="outer">
            
                

<aside id="profile">
    <div class="inner profile-inner">
        <div class="base-info profile-block">
            <img id="avatar" src="/css/images/avatar.png" />
            <h2 id="name">刘鑫</h2>
            <h3 id="title">一个热爱生活喜欢技术的程序猿</h3>
            <span id="location"><i class="fa fa-map-marker"></i>shanghai, China</span>
            <a id="follow" target="_blank" href="https://github.com/lxchinesszz">关注我</a>
        </div>
        <div class="article-info profile-block">
            <div class="article-info-block">
                25
                <span>文章</span>
            </div>
            <div class="article-info-block">
                19
                <span>标签</span>
            </div>
        </div>
        
        <div class="profile-block social-links">
            <table>
                <tr>
                    
                    
                    <td>
                        <a href="https://github.com/lxchinesszz" target="_blank" title="github" class=tooltip>
                            <i class="fa fa-github"></i>
                        </a>
                    </td>
                    
                    <td>
                        <a href="/" target="_blank" title="twitter" class=tooltip>
                            <i class="fa fa-twitter"></i>
                        </a>
                    </td>
                    
                    <td>
                        <a href="/" target="_blank" title="facebook" class=tooltip>
                            <i class="fa fa-facebook"></i>
                        </a>
                    </td>
                    
                    <td>
                        <a href="/" target="_blank" title="dribbble" class=tooltip>
                            <i class="fa fa-dribbble"></i>
                        </a>
                    </td>
                    
                    <td>
                        <a href="http://weibo.com/u/5513970927?is_all=1" target="_blank" title="weibo" class=tooltip>
                            <i class="fa fa-weibo"></i>
                        </a>
                    </td>
                    
                    <td>
                        <a href="/" target="_blank" title="rss" class=tooltip>
                            <i class="fa fa-rss"></i>
                        </a>
                    </td>
                    
                </tr>
            </table>
        </div>
        
    </div>
</aside>

            
            <section id="main">
    <article id="Layout-Spring整合Quartz2.1.1(执行中，得到application上下文，执行bean方法)" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/08/27/Spring整合Quartz2.1.1(执行中，得到application上下文，执行bean方法)/">Spring整合Quartz2.1.1(执行中，得到application上下文，执行bean方法)</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/08/27/Spring整合Quartz2.1.1(执行中，得到application上下文，执行bean方法)/">
            <time datetime="2016-08-26T16:00:00.000Z" itemprop="datePublished">2016-08-27</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/Spring整合Quartz2-1-1/">Spring整合Quartz2.1.1</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <blockquote>
<p>==前文==，Quartz中迭代后，变化很大，让我走了很多的误区，这里简单解释一点，希望大家可以跳过误区，建议大家从下往上读（希望对大家有点帮助），我是一只爱分享的小菜鸟</p>
</blockquote>
<ul>
<li>JobDetail和Trigger和Schedule都是接口，统统不能new</li>
</ul>
<h5 id="1-如果只是执行一些自定义的类，其实使用SpringBoot的自带的任务就可以完成，简单的不能想象。这个可以看-gt-我的另一篇SpringBoot原生定时任务解析。"><a href="#1-如果只是执行一些自定义的类，其实使用SpringBoot的自带的任务就可以完成，简单的不能想象。这个可以看-gt-我的另一篇SpringBoot原生定时任务解析。" class="headerlink" title="1.如果只是执行一些自定义的类，其实使用SpringBoot的自带的任务就可以完成，简单的不能想象。这个可以看-&gt;我的另一篇SpringBoot原生定时任务解析。"></a>1.如果只是执行一些自定义的类，其实使用SpringBoot的自带的任务就可以完成，简单的不能想象。这个可以看-&gt;我的另一篇SpringBoot原生定时任务解析。</h5><h5 id="2-如果要是要动态的执行一些有Spring管理的bean，可能要稍微费点功夫了，网上有很多的教程，那部分都是xml形式配置的，本人菜鸟一枚（十分迷惑），十分不喜欢xml配置，看着眼花，当程序读取的时候还是要解析java对象来执行的，那么为何不直接配置成配置类呢？这个问题先方下，以后会详细解释如何使用Spring-Boot配置类。"><a href="#2-如果要是要动态的执行一些有Spring管理的bean，可能要稍微费点功夫了，网上有很多的教程，那部分都是xml形式配置的，本人菜鸟一枚（十分迷惑），十分不喜欢xml配置，看着眼花，当程序读取的时候还是要解析java对象来执行的，那么为何不直接配置成配置类呢？这个问题先方下，以后会详细解释如何使用Spring-Boot配置类。" class="headerlink" title="2.如果要是要动态的执行一些有Spring管理的bean，可能要稍微费点功夫了，网上有很多的教程，那部分都是xml形式配置的，本人菜鸟一枚（十分迷惑），十分不喜欢xml配置，看着眼花，当程序读取的时候还是要解析java对象来执行的，那么为何不直接配置成配置类呢？这个问题先方下，以后会详细解释如何使用Spring Boot配置类。"></a>2.如果要是要动态的执行一些有Spring管理的bean，可能要稍微费点功夫了，网上有很多的教程，那部分都是xml形式配置的，本人菜鸟一枚（十分迷惑），十分不喜欢xml配置，看着眼花，当程序读取的时候还是要解析java对象来执行的，那么为何不直接配置成配置类呢？这个问题先方下，以后会详细解释如何使用Spring Boot配置类。</h5><h1 id="开始代码展示"><a href="#开始代码展示" class="headerlink" title="开始代码展示"></a>开始代码展示</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div></pre></td><td class="code"><pre><div class="line">    //job是一个接口，当定时任务执行的时候，就要运行这个方法，那么可以推测</div><div class="line">    JobExecutionContext这个对象中包含了我们可能使用的关于这个定时任务的所有细节，请看代码</div><div class="line">        </div><div class="line">public interface Job &#123;</div><div class="line">    void execute(JobExecutionContext var1) throws JobExecutionException;</div><div class="line">&#125;</div><div class="line"></div><div class="line">/**</div><div class="line"> * Created by liuxin on 16/12/21.</div><div class="line"> * 方案1：反射执行类和执行方法（不解析，没有用，刚开始走了误区，自己反射方法执行，大家尽量不要用）</div><div class="line"> * 方案2：读取bean（这个才是重点）</div><div class="line"> */</div><div class="line">public class ScheduledTasks implements Job &#123;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public void execute(JobExecutionContext jobExecutionContext) throws JobExecutionException &#123;</div><div class="line">        System.out.println(&quot;------进入定时方法区域-------&quot;);</div><div class="line">        try &#123;</div><div class="line">            ConfigurableApplicationContext cac = (ConfigurableApplicationContext) jobExecutionContext.getJobDetail().getJobDataMap().get(&quot;ConfigurableApplicationContext&quot;);</div><div class="line">            HelloService helloService = (HelloService) cac.getBean(&quot;helloService&quot;);</div><div class="line">            helloService.hh();</div><div class="line">        &#125; catch (Exception e) &#123;</div><div class="line">            </div><div class="line">        &#125;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<blockquote>
<p>上面的代码中看到这个JobExecutionContext可以得到JobDetail，而这个JobDetail对象是我们自己创建的用来详细介绍我们定时任务的，也就是我们要执行的方法的详细在这个里存放，<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div></pre></td><td class="code"><pre><div class="line">jobDetail.getJobDataMap().put(&quot;ConfigurableApplicationContext&quot;,cac);</div><div class="line">这个是我们在main方法中测试时候，提前放进去，的在执行execute方法时候，取到的上下文对象，用来得到bean的这么说是不是很清楚了？</div><div class="line">接着看代码</div></pre></td></tr></table></figure></p>
<p>测试的bean对象<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">@Service</div><div class="line">public class HelloService &#123;</div><div class="line">    static int i=0;</div><div class="line">    public void hh()&#123;</div><div class="line">        System.out.println(++i);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
<p>为了证明这个bean在上下文中，我们打印一下，上下文中的所有的bean</p>
</blockquote>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div></pre></td><td class="code"><pre><div class="line">@SpringBootApplication</div><div class="line">public class TestQuartzApplication &#123;</div><div class="line"></div><div class="line">    public static void main(String[] args) throws Exception &#123;</div><div class="line">        ConfigurableApplicationContext cac = SpringApplication.run(TestQuartzApplication.class, args);</div><div class="line">        String[] names = cac.getBeanDefinitionNames();</div><div class="line">        Arrays.asList(names).forEach(name -&gt; System.out.println(name));//打印bean 可以看到helloService在倒数3</div><div class="line"></div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"></div><div class="line">  .   ____          _            __ _ _</div><div class="line"> /\\ / ___&apos;_ __ _ _(_)_ __  __ _ \ \ \ \</div><div class="line">( ( )\___ | &apos;_ | &apos;_| | &apos;_ \/ _` | \ \ \ \</div><div class="line"> \\/  ___)| |_)| | | | | || (_| |  ) ) ) )</div><div class="line">  &apos;  |____| .__|_| |_|_| |_\__, | / / / /</div><div class="line"> =========|_|==============|___/=/_/_/_/</div><div class="line"> :: Spring Boot ::        (v1.4.2.RELEASE)</div><div class="line"></div><div class="line">org.springframework.context.annotation.internalConfigurationAnnotationProcessor</div><div class="line">org.springframework.context.annotation.internalAutowiredAnnotationProcessor</div><div class="line">org.springframework.context.annotation.internalRequiredAnnotationProcessor</div><div class="line">org.springframework.context.annotation.internalCommonAnnotationProcessor</div><div class="line">org.springframework.context.event.internalEventListenerProcessor</div><div class="line">org.springframework.context.event.internalEventListenerFactory</div><div class="line">testQuartzApplication</div><div class="line">org.springframework.boot.autoconfigure.internalCachingMetadataReaderFactory</div><div class="line">org.springframework.context.annotation.ConfigurationClassPostProcessor.importAwareProcessor</div><div class="line">org.springframework.context.annotation.ConfigurationClassPostProcessor.enhancedConfigurationProcessor</div><div class="line">helloService</div><div class="line">redisConfig</div><div class="line">jedis</div></pre></td></tr></table></figure>
<blockquote>
<p>那么现在的任务就是把，这个上下文对象防盗JobDetil的map中，2.2.1的区别来了，不在是一起new的jobDetail了,由JobBuilder和TriggerBuilder构建<br><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">@SpringBootApplication</div><div class="line">@EnableScheduling</div><div class="line">public class TestQuartzApplication &#123;</div><div class="line"></div><div class="line">    public static void main(String[] args) throws Exception &#123;</div><div class="line">        ConfigurableApplicationContext cac = SpringApplication.run(TestQuartzApplication.class, args);</div><div class="line">        String[] names = cac.getBeanDefinitionNames();</div><div class="line">        Arrays.asList(names).forEach(name -&gt; System.out.println(name));//打印bean</div><div class="line">        SchedulerFactory schedulerFactory = new StdSchedulerFactory();</div><div class="line">        Scheduler scheduler = schedulerFactory.getScheduler();</div><div class="line">        JobDetail jobDetail = JobBuilder.newJob(ScheduledTasks.class).withIdentity(&quot;testkey&quot;, &quot;testvalue&quot;).withDescription(&quot;一个测试的类&quot;).build();</div><div class="line">        jobDetail.getJobDataMap().put(&quot;ConfigurableApplicationContext&quot;,cac);//重点是这句话</div><div class="line">        Trigger trigger = TriggerBuilder.newTrigger().startNow().withSchedule(CronScheduleBuilder.cronSchedule(&quot;0/1 * * * * ?&quot;)).startNow().build();</div><div class="line">        scheduler.scheduleJob(jobDetail,trigger);</div><div class="line">        scheduler.start();</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure></p>
</blockquote>

        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/08/27/Spring整合Quartz2.1.1(执行中，得到application上下文，执行bean方法)/" data-id="cizk115fh001kjj8zhqrp54u0" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/08/27/Spring整合Quartz2.1.1(执行中，得到application上下文，执行bean方法)/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/08/27/Spring整合Quartz2.1.1(执行中，得到application上下文，执行bean方法)/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-SpringBoot整合Quartz-动态读取任务执行(2.2.1)" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/08/23/SpringBoot整合Quartz-动态读取任务执行(2.2.1)/">SpringBoot整合Quartz-动态读取任务执行(2.2.1)</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/08/23/SpringBoot整合Quartz-动态读取任务执行(2.2.1)/">
            <time datetime="2016-08-22T16:00:00.000Z" itemprop="datePublished">2016-08-23</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/动态读取任务执行/">动态读取任务执行</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <blockquote>
<p>本次使用redis作为数据库，存储定时任务类<br>redis的连接不是重点，重点是解析序列化处理过的任务数组和Quartz如何添加任务</p>
</blockquote>
<h1 id="1-JobEntity-用来保存执行任务类"><a href="#1-JobEntity-用来保存执行任务类" class="headerlink" title="1. JobEntity 用来保存执行任务类"></a>1. JobEntity 用来保存执行任务类</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">public class JobEntity implements Serializable &#123;</div><div class="line">    //cron表达式</div><div class="line">    private String cronExpression;</div><div class="line">    //组名</div><div class="line">    private String jobGroup = Scheduler.DEFAULT_GROUP;</div><div class="line">    </div><div class="line">    private String jobName;</div><div class="line"></div><div class="line">    private String className; // 执行任务的类(完整路径  包含包名)</div><div class="line"></div><div class="line">    private String methodName;//执行任务的方法名</div><div class="line"></div><div class="line">    set ...</div><div class="line">    get ...</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h1 id="2-任务类"><a href="#2-任务类" class="headerlink" title="2.任务类"></a>2.任务类</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div></pre></td><td class="code"><pre><div class="line">public class Test &#123;</div><div class="line">    public void xun()&#123;</div><div class="line">        System.out.println(&quot;--------定时任务2-------&quot;);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line">public class Test2 &#123;</div><div class="line">    public void test()&#123;</div><div class="line">        System.out.println(&quot;--------定时任务1-------&quot;);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h1 id="3-存入redis"><a href="#3-存入redis" class="headerlink" title="3.存入redis"></a>3.存入redis</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div></pre></td><td class="code"><pre><div class="line">public void start2() &#123;</div><div class="line">        Gson gson = new Gson();</div><div class="line">        JobEntity jobEntity = new JobEntity();</div><div class="line">        jobEntity.setMethodName(&quot;test&quot;);</div><div class="line">        jobEntity.setJobName(&quot;MyJob2&quot;);</div><div class="line">        jobEntity.setClassName(&quot;zebra.shjf.schedule.Test2&quot;);</div><div class="line">        jobEntity.setCronExpression(&quot;0/1 * * * * ?&quot;);</div><div class="line">        jobEntity.setJobGroup(&quot;MyGroup2&quot;);</div><div class="line"></div><div class="line">        JobEntity jobEntity2 = new JobEntity();</div><div class="line">        jobEntity2.setMethodName(&quot;xun&quot;);</div><div class="line">        jobEntity2.setJobName(&quot;MyJob&quot;);</div><div class="line">        jobEntity2.setClassName(&quot;zebra.shjf.schedule.Test&quot;);</div><div class="line">        jobEntity2.setCronExpression(&quot;0/1 * * * * ?&quot;);</div><div class="line">        jobEntity2.setJobGroup(&quot;MyGroup&quot;);</div><div class="line"></div><div class="line">        ArrayList&lt;JobEntity&gt; list = new ArrayList&lt;JobEntity&gt;();</div><div class="line">        list.add(jobEntity);</div><div class="line">        list.add(jobEntity2);</div><div class="line">        jedis.set(&quot;jobEntity&quot;, gson.toJson(list));</div><div class="line">    &#125;</div><div class="line"> 127.0.0.1:6379&gt; get &quot;jobEntity&quot;</div><div class="line">    &quot;[&#123;\&quot;cronExpression\&quot;:\&quot;0/1 * * * * ?\&quot;,\&quot;jobGroup\&quot;:\&quot;MyGroup2\&quot;,\&quot;jobName\&quot;:\&quot;MyJob2\&quot;,\&quot;className\&quot;:\&quot;zebra.shjf.schedule.Test2\&quot;,\&quot;methodName\&quot;:\&quot;test\&quot;&#125;,&#123;\&quot;cronExpression\&quot;:\&quot;0/1 * * * * ?\&quot;,\&quot;jobGroup\&quot;:\&quot;MyGroup\&quot;,\&quot;jobName\&quot;:\&quot;MyJob\&quot;,\&quot;className\&quot;:\&quot;zebra.shjf.schedule.Test\&quot;,\&quot;methodName\&quot;:\&quot;xun\&quot;&#125;]&quot;</div></pre></td></tr></table></figure>
<h1 id="3-重点解析-注释解释"><a href="#3-重点解析-注释解释" class="headerlink" title="3.重点解析(注释解释)"></a>3.重点解析(注释解释)</h1><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div></pre></td><td class="code"><pre><div class="line">@Test</div><div class="line"> public void start3() throws Exception &#123;</div><div class="line">     //准备添加从redis中得到的实体类，目的是遍历，然后添加到定时容器中，去执行</div><div class="line">     ArrayList&lt;JobEntity&gt;arrayList=new ArrayList&lt;JobEntity&gt;();</div><div class="line"></div><div class="line">     Gson gson = new Gson();</div><div class="line">     //从redis中得到json数组对象</div><div class="line">     String str = jedis.get(&quot;jobEntity&quot;);</div><div class="line">     //json解析器</div><div class="line">     JsonParser parser = new JsonParser();</div><div class="line">     //解析出json元素，jsonElement对象中有一些方法判断是对象还是数组，各对应不同的处理</div><div class="line">     JsonElement jsonElement = parser.parse(str);</div><div class="line"></div><div class="line">     //如果是json数组就转换为jsonArray</div><div class="line">     JsonArray jsonArray = null;</div><div class="line">     if (jsonElement.isJsonArray()) &#123;</div><div class="line">         jsonArray = jsonElement.getAsJsonArray();</div><div class="line">     &#125;</div><div class="line">     //遍历</div><div class="line">     Iterator it= jsonArray.iterator();</div><div class="line">     while (it.hasNext())&#123;</div><div class="line">         JsonElement e = (JsonElement)it.next();</div><div class="line">         //把获得的数组中每一个对象，重新添加到数组中</div><div class="line">         arrayList.add(gson.fromJson(e,JobEntity.class));</div><div class="line">     &#125;</div><div class="line">     //容器</div><div class="line">     Scheduler scheduler=null;</div><div class="line">     //遍历数组</div><div class="line">     for(JobEntity jobEntity:arrayList)&#123;</div><div class="line">         //遍历获得每个job对象</div><div class="line">         JobDetail jobDetail = JobBuilder.newJob(ScheduledTasks.class).withIdentity(jobEntity.getJobName(), jobEntity.getJobGroup()).//</div><div class="line">                 usingJobData(&quot;className&quot;, jobEntity.getClassName())</div><div class="line">                 .usingJobData(&quot;methodName&quot;, jobEntity.getMethodName()).build();</div><div class="line">         //jobDetail.getJobDataMap().put(&quot;test&quot;, jobEntity);</div><div class="line">         //为每个任务动态构建表达式</div><div class="line">         CronScheduleBuilder cron = CronScheduleBuilder.cronSchedule(jobEntity.getCronExpression());</div><div class="line">         //构建触发器</div><div class="line">         CronTrigger trigger = TriggerBuilder.newTrigger().withIdentity(jobEntity.getJobName(), jobEntity.getJobGroup()).withSchedule(cron).build();</div><div class="line"></div><div class="line">         SchedulerFactory schedulerFactory = new StdSchedulerFactory();</div><div class="line">         scheduler = schedulerFactory.getScheduler();</div><div class="line">         scheduler.scheduleJob(jobDetail, trigger);</div><div class="line">     &#125;</div><div class="line">     scheduler.start();</div><div class="line"></div><div class="line">     Thread thread = new Thread();</div><div class="line">     thread.sleep(10000);</div><div class="line"></div><div class="line"> &#125;</div></pre></td></tr></table></figure>
        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/08/23/SpringBoot整合Quartz-动态读取任务执行(2.2.1)/" data-id="cizk115e6001ajj8z5ldo167u" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/08/23/SpringBoot整合Quartz-动态读取任务执行(2.2.1)/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/08/23/SpringBoot整合Quartz-动态读取任务执行(2.2.1)/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-SpringBoot+Quartz整合定时任务(1.8.6)" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/08/16/SpringBoot+Quartz整合定时任务(1.8.6)/">SpringBoot+Quartz整合定时任务(1.8.6)</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/08/16/SpringBoot+Quartz整合定时任务(1.8.6)/">
            <time datetime="2016-08-15T16:00:00.000Z" itemprop="datePublished">2016-08-16</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/整合定时任务/">整合定时任务</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <h1 id="概念："><a href="#概念：" class="headerlink" title="概念："></a>概念：</h1><ul>
<li>当处理一些，简单的，固定时间，重复次数的任务可以使用简单触发器</li>
<li>当处理一些，负载的任务，可以使用Cron表达式（触发器的name字段一定要写）<h2 id="1-一个jobDetail就是一个业务。也就是准备定时的任务"><a href="#1-一个jobDetail就是一个业务。也就是准备定时的任务" class="headerlink" title="1.一个jobDetail就是一个业务。也就是准备定时的任务"></a>1.一个jobDetail就是一个业务。也就是准备定时的任务</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">@Bean</div><div class="line">   public JobDetail jobDetail()&#123;</div><div class="line">       JobDetail jobDetail=new JobDetail(&quot;scheduledTasks2s&quot;, Scheduler.DEFAULT_GROUP, ScheduledTasks2.class);</div><div class="line">       return jobDetail;</div><div class="line">   &#125;</div></pre></td></tr></table></figure>
</li>
</ul>
<h2 id="2-SimpleTrigger简单触发器，设置多久触发一次，触发次数"><a href="#2-SimpleTrigger简单触发器，设置多久触发一次，触发次数" class="headerlink" title="2.SimpleTrigger简单触发器，设置多久触发一次，触发次数"></a>2.SimpleTrigger简单触发器，设置多久触发一次，触发次数</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div></pre></td><td class="code"><pre><div class="line"> @Bean</div><div class="line">public SimpleTrigger simpleTrigger()&#123;</div><div class="line">    SimpleTrigger simpleTrigger=new SimpleTrigger(&quot;simpleTrigger&quot;,Scheduler.DEFAULT_GROUP);</div><div class="line">    simpleTrigger.setStartTime(new Date(System.currentTimeMillis()));</div><div class="line">    simpleTrigger.setRepeatInterval(5000);//没</div><div class="line">    simpleTrigger.setRepeatCount(10);//执行10次</div><div class="line">    return simpleTrigger;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="2-1可以使用cron表达式的触发器"><a href="#2-1可以使用cron表达式的触发器" class="headerlink" title="2.1可以使用cron表达式的触发器"></a>2.1可以使用cron表达式的触发器</h2><pre><code>/**
 * 触发器名字一定要写
 * @return
 * @throws Exception
 */
@Bean
public CronTrigger cronTrigger() throws Exception {
    CronTrigger cronTrigger = new CronTrigger();
    cronTrigger.setName(&quot;MyCronTrigger&quot;);
    cronTrigger.setCronExpression(&quot;0/1 * * * * ? &quot;);
    return cronTrigger;
}
</code></pre><h2 id="3-Scheduler调度器，这个调度器由SchedulerFactory工厂获得设置定时任务和触-发器"><a href="#3-Scheduler调度器，这个调度器由SchedulerFactory工厂获得设置定时任务和触-发器" class="headerlink" title="3.Scheduler调度器，这个调度器由SchedulerFactory工厂获得设置定时任务和触    发器"></a>3.Scheduler调度器，这个调度器由SchedulerFactory工厂获得设置定时任务和触    发器</h2><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line">@Bean</div><div class="line">    public Scheduler scheduler(JobDetail jobDetail,SimpleTrigger simpleTrigger)throws Exception&#123;</div><div class="line">        SchedulerFactory schedulerFactory=new StdSchedulerFactory();</div><div class="line">        Scheduler scheduler=schedulerFactory.getScheduler();</div><div class="line">        scheduler.scheduleJob(jobDetail, simpleTrigger);</div><div class="line">        return scheduler;</div><div class="line">    &#125;</div></pre></td></tr></table></figure>
        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/08/16/SpringBoot+Quartz整合定时任务(1.8.6)/" data-id="cizk115dg000rjj8zskzuf7d7" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/08/16/SpringBoot+Quartz整合定时任务(1.8.6)/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/08/16/SpringBoot+Quartz整合定时任务(1.8.6)/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-SpringBoot使用maven打包，加载不到配置文件原因" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/08/10/SpringBoot使用maven打包，加载不到配置文件原因/">SpringBoot使用maven打包，加载不到配置文件原因</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/08/10/SpringBoot使用maven打包，加载不到配置文件原因/">
            <time datetime="2016-08-09T16:00:00.000Z" itemprop="datePublished">2016-08-10</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/配置文件加载/">配置文件加载</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <h1 id="病情"><a href="#病情" class="headerlink" title="病情"></a>病情</h1><p>使用idea工具，测试没有问题，使用maven可以打包，但是运行，错误。</p>
<p>通过反编译分析，原因就是打包后的文件，没有包配置文件输入，解决办法</p>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div></pre></td><td class="code"><pre><div class="line">&lt;resources&gt;</div><div class="line">    &lt;resource&gt;</div><div class="line">        &lt;directory&gt;src/main/resources&lt;/directory&gt;</div><div class="line">        &lt;includes&gt;</div><div class="line">            &lt;include&gt;**/*.xml&lt;/include&gt;</div><div class="line">            &lt;include&gt;**/*.properties&lt;/include&gt;</div><div class="line">        &lt;/includes&gt;</div><div class="line">    &lt;/resource&gt;</div><div class="line">    &lt;resource&gt;</div><div class="line">        &lt;directory&gt;src/main/java&lt;/directory&gt;</div><div class="line">        &lt;includes&gt;</div><div class="line">            &lt;include&gt;**/*.properties&lt;/include&gt;</div><div class="line">        &lt;/includes&gt;</div><div class="line">    &lt;/resource&gt;</div><div class="line">&lt;/resources&gt;</div></pre></td></tr></table></figure>
        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/08/10/SpringBoot使用maven打包，加载不到配置文件原因/" data-id="cizk115dm000wjj8zviihmtva" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/08/10/SpringBoot使用maven打包，加载不到配置文件原因/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/08/10/SpringBoot使用maven打包，加载不到配置文件原因/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-SpringBoot原生定时任务解析" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/08/01/SpringBoot原生定时任务解析/">SpringBoot原生定时任务解析</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/08/01/SpringBoot原生定时任务解析/">
            <time datetime="2016-07-31T16:00:00.000Z" itemprop="datePublished">2016-08-01</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/SpringBoot原生定时任务解析/">SpringBoot原生定时任务解析</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <p>#SpringBoot原生定时任务，不需要引入任何依赖</p>
<p>==只要了解，几个注解就可以使用==</p>
<ul>
<li>1.在启动类上加入@EnableScheduling标签</li>
<li>2.在定时任务方法上加入@Schedule(fixedDelay=5000)</li>
<li>3.就是如此简单，简单的不可想象</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div></pre></td><td class="code"><pre><div class="line">package zebra.shjf;</div><div class="line"></div><div class="line">import org.springframework.boot.SpringApplication;</div><div class="line">import org.springframework.boot.autoconfigure.SpringBootApplication;</div><div class="line">import org.springframework.context.ConfigurableApplicationContext;</div><div class="line">import org.springframework.scheduling.annotation.EnableScheduling;</div><div class="line"></div><div class="line">@SpringBootApplication</div><div class="line">@EnableScheduling</div><div class="line">public class TestQuartzApplication &#123;</div><div class="line"></div><div class="line">    public static void main(String[] args) &#123;</div><div class="line">        SpringApplication.run(TestQuartzApplication.class, args);</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line"></div><div class="line">@Component</div><div class="line">public class ScheduledTasks&#123;</div><div class="line">    @Scheduled(fixedDelay = 5000)</div><div class="line">    public void execute() &#123;</div><div class="line">        System.out.println(&quot;当前时间：&quot; + new Date());</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/08/01/SpringBoot原生定时任务解析/" data-id="cizk115dy0013jj8zqq9mpchp" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/08/01/SpringBoot原生定时任务解析/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/08/01/SpringBoot原生定时任务解析/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-Spring Boot项目中自定义注解的使用" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/07/29/Spring Boot项目中自定义注解的使用/">Spring Boot项目中自定义注解的使用</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/07/29/Spring Boot项目中自定义注解的使用/">
            <time datetime="2016-07-28T16:00:00.000Z" itemprop="datePublished">2016-07-29</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/Spring-Boot注解/">Spring Boot注解</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <h2 id="Spring-Boot项目中自定义注解的使用"><a href="#Spring-Boot项目中自定义注解的使用" class="headerlink" title="Spring Boot项目中自定义注解的使用"></a>Spring Boot项目中自定义注解的使用</h2><blockquote>
<p>项目中常常要打印日志，尤其是在做接口开发中，因为要面临着对前台数据的检查，在这种情况下，如果还是只使用普通的日志方式，如果配置为INFO 那么明显打印的东西是在太多了，在无奈的压迫下，小编我最终还是选择自己使用Aop的方式去记录日志信息，以下是实战演练。</p>
</blockquote>
<p>作者：<a href="https://lxchinesszz.github.io/" target="_blank" rel="external">@lxchinesszz</a></p>
<p>本文为作者原创，转载请注明出处</p>
<h3 id="1-定义注解接口"><a href="#1-定义注解接口" class="headerlink" title="1.定义注解接口"></a>1.定义注解接口</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/**</span></div><div class="line"> * <span class="doctag">@Package</span>: com.example.config</div><div class="line"> * <span class="doctag">@Description</span>: 定制一个接口</div><div class="line"> * <span class="doctag">@author</span>: liuxin</div><div class="line"> * <span class="doctag">@date</span>: 17/2/23 下午4:20</div><div class="line"> */</div><div class="line"><span class="meta">@Documented</span></div><div class="line"><span class="meta">@Retention</span>(RUNTIME)</div><div class="line"><span class="meta">@Target</span>(METHOD)</div><div class="line"><span class="keyword">public</span> <span class="meta">@interface</span> MyLog &#123;</div><div class="line">    <span class="function">String <span class="title">value</span><span class="params">()</span> <span class="keyword">default</span> "日志注解"</span>;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>[^Documented 注解]: Documented 注解表明这个注解应该被 javadoc工具记录. 默认情况下,javadoc是不包括注解的. 但如果声明注解时指定了 @Documented,则它会被 javadoc 之类的工具处理, 所以注解类型信息也会被包括在生成的文档中<br>[^Inherited 注解]: 它指明被注解的类会自动继承. 更具体地说,如果定义注解时使用了 @Inherited 标记,然后用定义的注解来标注另一个父类, 父类又有一个子类(subclass),则父类的所有属性将被继承到它的子类中</p>
<ul>
<li>@Target(ElementType.TYPE)   //接口、类、枚举、注解</li>
<li>@Target(ElementType.FIELD) //字段、枚举的常量</li>
<li>@Target(ElementType.METHOD) //方法</li>
<li>@Target(ElementType.PARAMETER) //方法参数</li>
<li>@Target(ElementType.CONSTRUCTOR)  //构造函数</li>
<li>@Target(ElementType.LOCAL_VARIABLE)//局部变量</li>
<li>@Target(ElementType.ANNOTATION_TYPE)//注解</li>
<li>@Target(ElementType.PACKAGE) ///包   </li>
</ul>
<ul>
<li><code>1.RetentionPolicy.SOURCE —— 这种类型的Annotations只在源代码级别保留,编译时就会被忽略</code></li>
<li><code>2.RetentionPolicy.CLASS —— 这种类型的Annotations编译时被保留,在class文件中存在,但JVM将会忽略</code></li>
<li><code>3.RetentionPolicy.RUNTIME —— 这种类型的Annotations将被JVM保留,所以他们能在运行时被JVM或其他使用反射机制的代码所读取和使用.</code></li>
</ul>
<h3 id="2-通过切面来实现注解"><a href="#2-通过切面来实现注解" class="headerlink" title="2.通过切面来实现注解"></a>2.通过切面来实现注解</h3><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div></pre></td><td class="code"><pre><div class="line">/**</div><div class="line"> * @Package: com.example.config</div><div class="line"> * @Description: MyLog的实现类</div><div class="line"> * @author: liuxin</div><div class="line"> * @date: 17/2/23 下午4:22</div><div class="line"> */</div><div class="line">@Component</div><div class="line">@Aspect</div><div class="line">public class LogAspect &#123;</div><div class="line">    @Pointcut(&quot;@annotation(com.example.config.MyLog)&quot;)</div><div class="line">    private void cut() &#123; &#125;</div><div class="line"></div><div class="line">    /**</div><div class="line">     * 定制一个环绕通知</div><div class="line">     * @param joinPoint</div><div class="line">     */</div><div class="line">    @Around(&quot;cut()&quot;)</div><div class="line">    public void advice(ProceedingJoinPoint joinPoint)&#123;</div><div class="line">        System.out.println(&quot;环绕通知之开始&quot;);</div><div class="line">        try &#123;</div><div class="line">            joinPoint.proceed();</div><div class="line">        &#125; catch (Throwable e) &#123;</div><div class="line">            e.printStackTrace();</div><div class="line">        &#125;</div><div class="line">        System.out.println(&quot;环绕通知之结束&quot;);</div><div class="line">    &#125;</div><div class="line">    </div><div class="line">       //当想获得注解里面的属性，可以直接注入改注解</div><div class="line">        @Before(&quot;cut()&amp;&amp;@annotation(myLog)&quot;)</div><div class="line">            public void record(JoinPoint joinPoint, MyLog myLog) &#123;</div><div class="line">            System.out.println(myLog.value());</div><div class="line">        &#125;</div><div class="line">    </div><div class="line">    @After(&quot;recordLog()&quot;)</div><div class="line">    public void after() &#123;</div><div class="line">        this.printLog(&quot;已经记录下操作日志@After 方法执行后&quot;);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<blockquote>
<p>因为Aspect作用在bean上，所以先用Component把这个类添加到容器中</p>
<p>@Pointcut 定义要拦截的注解</p>
<p>至于切面表达式，不需要你记住，小编我也记不住，用的时候查一下就可以了</p>
<p>切面表达式<a href="http://lavasoft.blog.51cto.com/62575/172292/" target="_blank" rel="external">link</a></p>
<p>@After</p>
<p>@Before</p>
<p>@Around</p>
<p>就不用解释了。</p>
</blockquote>
<h4 id="2-1-获得注解中的变量"><a href="#2-1-获得注解中的变量" class="headerlink" title="2.1 获得注解中的变量"></a>2.1 获得注解中的变量</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div></pre></td><td class="code"><pre><div class="line">//当想获得注解里面的属性，可以直接注入改注解</div><div class="line">  @Before(&quot;cut()&amp;&amp;@annotation(myLog)&quot;)</div><div class="line">      public void record(JoinPoint joinPoint, MyLog myLog) &#123;</div><div class="line">      System.out.println(myLog.value());</div><div class="line">  &#125;</div></pre></td></tr></table></figure>
<h4 id="2-2-注解中的ProceedingJoinPoint和JoinPoint说明"><a href="#2-2-注解中的ProceedingJoinPoint和JoinPoint说明" class="headerlink" title="2.2 注解中的ProceedingJoinPoint和JoinPoint说明"></a>2.2 注解中的<code>ProceedingJoinPoint</code>和<code>JoinPoint</code>说明</h4><blockquote>
<p>AspectJ使用org.aspectj.lang.JoinPoint接口表示目标类连接点对象，如果是环绕增强时，使用org.aspectj.lang.ProceedingJoinPoint表示连接点对象，该类是JoinPoint的子接口。任何一个增强方法都可以通过将第一个入参声明为JoinPoint访问到连接点上下文的信息。我们先来了解一下这两个接口的主要方法： </p>
</blockquote>
<ul>
<li><strong>1.JoinPoint </strong><ul>
<li> java.lang.Object[] getArgs()：获取连接点方法运行时的入参列表； </li>
<li> Signature getSignature() ：获取连接点的方法签名对象； </li>
<li> java.lang.Object getTarget() ：获取连接点所在的目标对象； </li>
<li> java.lang.Object getThis() ：获取代理对象本身； </li>
</ul>
</li>
<li><strong>2.ProceedingJoinPoint </strong><ul>
<li>ProceedingJoinPoint继承JoinPoint子接口，它新增了两个用于执行连接点方法的方法： </li>
<li> java.lang.Object proceed() throws java.lang.Throwable：通过反射执行目标对象的连接点处的方法； </li>
<li> java.lang.Object proceed(java.lang.Object[] args) throws java.lang.Throwable：通过反射执行目标对象连接点处的方法，不过使用新的入参替换原来的入参。 </li>
</ul>
</li>
</ul>
<h4 id="3-演示"><a href="#3-演示" class="headerlink" title="3.演示"></a>3.演示</h4><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div></pre></td><td class="code"><pre><div class="line">@RestController</div><div class="line">public class JsonRest &#123;</div><div class="line">    @MyLog</div><div class="line">    @RequestMapping(&quot;/log&quot;)</div><div class="line">    public String getLog()&#123;</div><div class="line">        return &quot;&lt;h1&gt;Hello World&lt;/h1&gt;&quot;;</div><div class="line">    &#125;</div><div class="line">&#125;</div><div class="line"></div><div class="line">当访问的时候会打印出：[因为小编只用了环绕通知]</div><div class="line">  环绕通知之开始</div><div class="line">  环绕通知之结束</div></pre></td></tr></table></figure>
        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/07/29/Spring Boot项目中自定义注解的使用/" data-id="cizk115bj0006jj8zbwkp5lhp" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/07/29/Spring Boot项目中自定义注解的使用/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/07/29/Spring Boot项目中自定义注解的使用/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-Spring Boot配置拦截器" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/07/27/Spring Boot配置拦截器/">SpringBoot拦截器</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/07/27/Spring Boot配置拦截器/">
            <time datetime="2016-07-26T16:00:00.000Z" itemprop="datePublished">2016-07-27</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/SpringBoot拦截器/">SpringBoot拦截器</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <h1 id="SpringBoot拦截器"><a href="#SpringBoot拦截器" class="headerlink" title="SpringBoot拦截器"></a>SpringBoot拦截器</h1><blockquote>
<p>最近项目中有一个需求，对来访的请求，进行计算，记录下业务处理时间。Spring Boot项目中使用拦截器，超级简单，再次说明一下用法。相信大家一看便懂。</p>
</blockquote>
<h3 id="1-继承-HandlerInterceptor-实现具体的处理逻辑"><a href="#1-继承-HandlerInterceptor-实现具体的处理逻辑" class="headerlink" title="1.继承 HandlerInterceptor 实现具体的处理逻辑"></a>1.继承 HandlerInterceptor 实现具体的处理逻辑</h3><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div></pre></td><td class="code"><pre><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">interface</span> <span class="title">HandlerInterceptor</span> </span>&#123;</div><div class="line">    <span class="function"><span class="keyword">boolean</span> <span class="title">preHandle</span><span class="params">(HttpServletRequest var1, HttpServletResponse var2, Object var3)</span> <span class="keyword">throws</span> Exception</span>; <span class="comment">//是否放行</span></div><div class="line"></div><div class="line">    <span class="function"><span class="keyword">void</span> <span class="title">postHandle</span><span class="params">(HttpServletRequest var1, HttpServletResponse var2, Object var3, ModelAndView var4)</span> <span class="keyword">throws</span> Exception</span>; <span class="comment">//处理结束</span></div><div class="line"></div><div class="line">    <span class="function"><span class="keyword">void</span> <span class="title">afterCompletion</span><span class="params">(HttpServletRequest var1, HttpServletResponse var2, Object var3, Exception var4)</span> <span class="keyword">throws</span> Exception</span>; <span class="comment">//在处理结束后执行，最后执行的方法</span></div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p><strong>以下是我的处理逻辑</strong></p>
<figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/**</span></div><div class="line"> * <span class="doctag">@Package</span>: foxlife.base.interceptor</div><div class="line"> * <span class="doctag">@Description</span>: 处理时间拦截器，记录下，接口处理时间</div><div class="line"> * <span class="doctag">@author</span>: liuxin</div><div class="line"> * <span class="doctag">@date</span>: 17/2/22 上午10:58</div><div class="line"> */</div><div class="line"><span class="meta">@Component</span></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">ChanelInterceptor</span> <span class="keyword">implements</span> <span class="title">HandlerInterceptor</span> </span>&#123;</div><div class="line">    <span class="keyword">private</span> <span class="keyword">static</span> Logger logger = LoggerFactory.getLogger(ChanelInterceptor.class);</div><div class="line"></div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">boolean</span> <span class="title">preHandle</span><span class="params">(HttpServletRequest request, HttpServletResponse response, Object o)</span> <span class="keyword">throws</span> Exception </span>&#123;</div><div class="line">        logger.info(<span class="string">"============================拦截器启动=============================="</span>);</div><div class="line">        request.setAttribute(<span class="string">"starttime"</span>,System.currentTimeMillis());</div><div class="line">        <span class="keyword">return</span> <span class="keyword">true</span>;</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">postHandle</span><span class="params">(HttpServletRequest request, HttpServletResponse response, Object o, ModelAndView modelAndView)</span> <span class="keyword">throws</span> Exception </span>&#123;</div><div class="line">        logger.info(<span class="string">"===========================执行处理完毕============================="</span>);</div><div class="line">        <span class="keyword">long</span> starttime = (<span class="keyword">long</span>) request.getAttribute(<span class="string">"starttime"</span>);</div><div class="line">        request.removeAttribute(<span class="string">"starttime"</span>);</div><div class="line">        <span class="keyword">long</span> endtime = System.currentTimeMillis();</div><div class="line">        logger.info(<span class="string">"============请求地址："</span>+request.getRequestURI()+<span class="string">"：处理时间：&#123;&#125;"</span>,(endtime-starttime)+<span class="string">"ms"</span>);</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">afterCompletion</span><span class="params">(HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse, Object o, Exception e)</span> <span class="keyword">throws</span> Exception </span>&#123;</div><div class="line">        logger.info(<span class="string">"============================拦截器关闭=============================="</span>);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<h2 id="2-配置拦截器到应用中"><a href="#2-配置拦截器到应用中" class="headerlink" title="2.配置拦截器到应用中"></a>2.配置拦截器到应用中</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div></pre></td><td class="code"><pre><div class="line"><span class="comment">/**</span></div><div class="line"> * <span class="doctag">@Package</span>: foxlife.base.config</div><div class="line"> * <span class="doctag">@Description</span>: 配置拦截器</div><div class="line"> * <span class="doctag">@author</span>: liuxin</div><div class="line"> * <span class="doctag">@date</span>: 17/2/22 上午11:04</div><div class="line"> */</div><div class="line"><span class="meta">@Configuration</span></div><div class="line"><span class="keyword">public</span> <span class="class"><span class="keyword">class</span> <span class="title">MyInterceptorConfig</span> <span class="keyword">extends</span> <span class="title">WebMvcConfigurerAdapter</span></span>&#123;</div><div class="line">    <span class="meta">@Override</span></div><div class="line">    <span class="function"><span class="keyword">public</span> <span class="keyword">void</span> <span class="title">addInterceptors</span><span class="params">(InterceptorRegistry registry)</span> </span>&#123;</div><div class="line">        registry.addInterceptor(<span class="keyword">new</span> ChanelInterceptor()).addPathPatterns(<span class="string">"/**"</span>);</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
<p>[^注解]: Spring Boot的项目建议使用配置类,<code>addPathPatterns(&quot;/**&quot;)</code></p>
<h2 id="3-演示"><a href="#3-演示" class="headerlink" title="3.演示"></a>3.演示</h2><figure class="highlight java"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div></pre></td><td class="code"><pre><div class="line"><span class="number">2017</span>-<span class="number">02</span>-<span class="number">23</span> <span class="number">15</span>:<span class="number">40</span>:<span class="number">43.619</span>  INFO <span class="number">64568</span> --- [io-<span class="number">31024</span>-exec-<span class="number">3</span>] f.base.interceptor.ChanelInterceptor     : ============================拦截器启动==============================</div><div class="line"><span class="number">2017</span>-<span class="number">02</span>-<span class="number">23</span> <span class="number">15</span>:<span class="number">40</span>:<span class="number">43.621</span>  INFO <span class="number">64568</span> --- [io-<span class="number">31024</span>-exec-<span class="number">3</span>] f.base.interceptor.ChanelInterceptor     : ===========================执行处理完毕=============================</div><div class="line"><span class="number">2017</span>-<span class="number">02</span>-<span class="number">23</span> <span class="number">15</span>:<span class="number">40</span>:<span class="number">43.621</span>  INFO <span class="number">64568</span> --- [io-<span class="number">31024</span>-exec-<span class="number">3</span>] f.base.interceptor.ChanelInterceptor     : ============请求地址：/error：处理时间：<span class="number">2</span>ms</div><div class="line"><span class="number">2017</span>-<span class="number">02</span>-<span class="number">23</span> <span class="number">15</span>:<span class="number">40</span>:<span class="number">43.621</span>  INFO <span class="number">64568</span> --- [io-<span class="number">31024</span>-exec-<span class="number">3</span>] f.base.interceptor.ChanelInterceptor     : ============================拦截器关闭==============================</div></pre></td></tr></table></figure>

        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/07/27/Spring Boot配置拦截器/" data-id="cizk115be0005jj8z2dwnyqc9" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/07/27/Spring Boot配置拦截器/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/07/27/Spring Boot配置拦截器/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-SpringBoot优化方案" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/06/21/SpringBoot优化方案/">SpringBoot优化方案</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/06/21/SpringBoot优化方案/">
            <time datetime="2016-06-20T16:00:00.000Z" itemprop="datePublished">2016-06-21</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/优化方案/">优化方案</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <p>#Bean优化</p>
<p>1.当使用@SpringBootApplication会默认注册pom文件中拥有的为bean</p>
<pre><code>默认情况下自动获取应用配置信息，会加载一些不需要的beans
增加cpu消耗

beanNames个数：261    
堆内存：150-220M
</code></pre><p>2.使用@Configuration和@EnableAutoConfiguration</p>
<pre><code>beanNames个数：158
</code></pre><p>3.使用【不建议使用】</p>
<pre><code>使用mvn spring-boot:run -Ddebug 只用装配30个左右组件就能启动        
注解解释：

@EnableAutoConfiguration会自动加载可能需要的配置信息
在知道需要的beans的情况下，可以使用@Import方式去配置
</code></pre><p>4.生产环境下禁止xml校验</p>
<pre><code>继承XmlWebApplicationContext复写init

在web.xml文件中配置
    &lt;context-param&gt;
          &lt;param-name&gt;contextClass&lt;/param-name&gt;
          &lt;param-value&gt;com.example.CustomXmlWebApplicationContext&lt;/param-value&gt;
    &lt;/context-param&gt;
</code></pre><p>5.减少自动扫描，尽量使用配置形式，减少初始化扫描时间</p>
<p>6.使用延迟初始化的bean 【Using Lazy-Initialized Beans】</p>
<pre><code>lazy-init属性为true
spring初始化bean就能立即发现其错误，并进行错误处理，造成的负面效应增加了应用程序的加    载时间
</code></pre><p>优化方案：</p>
<pre><code>【jvisualvm】        
1.不适用默认方式，采用第二种减少注册bean数量，项目中需要
    的bean，采用注解方式在配置类中注册。
2.tomcat8，新特性8.5.6
      Servlet 3.1、JSP 2.3、EL 3.0
      Servlet 3.1实现了非阻塞式的I/O通信，性能得到
      巨大的改进
</code></pre><p>参考资料：</p>
<p>阿里云栖社区<a href="https://yq.aliyun.com/articles/2360" target="_blank" rel="external">link</a></p>
<p>51CTO开发频道<a href="http://developer.51cto.com/art/201404/435983.htm" target="_blank" rel="external">link</a></p>
<p>Spring Boot性能优化<a href="https://segmentfault.com/a/1190000004252885" target="_blank" rel="external">link</a></p>
<p>Google Cloud Platform优化<a href="https://cloud.google.com/appengine/articles/spring_optimization" target="_blank" rel="external">link</a></p>
<p>Spring Boot内存优化-DZone<a href="https://dzone.com/articles/spring-boot-memory-performance" target="_blank" rel="external">link</a></p>

        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/06/21/SpringBoot优化方案/" data-id="cizk115dj000tjj8z17vpqfah" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/06/21/SpringBoot优化方案/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/06/21/SpringBoot优化方案/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-SpringBoot配置视图" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/06/14/SpringBoot配置视图/">SpringBoot配置视图</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/06/14/SpringBoot配置视图/">
            <time datetime="2016-06-13T16:00:00.000Z" itemprop="datePublished">2016-06-14</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/SpringBoot配置视图/">SpringBoot配置视图</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div></pre></td><td class="code"><pre><div class="line">@Configuration</div><div class="line">@EnableWebMvc</div><div class="line">public class ApplicationConfigurerAdapter extends WebMvcConfigurerAdapter &#123;</div><div class="line"></div><div class="line">    @Override</div><div class="line">    public void configureDefaultServletHandling(DefaultServletHandlerConfigurer configurer) &#123;</div><div class="line">        configurer.enable();</div><div class="line">    &#125;</div><div class="line"></div><div class="line">    @Bean</div><div class="line">    public InternalResourceViewResolver viewResolver() &#123;</div><div class="line">        InternalResourceViewResolver resolver = new InternalResourceViewResolver();</div><div class="line">        resolver.setPrefix(&quot;WEB-INF/html&quot;);</div><div class="line">        resolver.setSuffix(&quot;.html&quot;);</div><div class="line">        return resolver;</div><div class="line">    &#125;</div><div class="line">&#125;</div></pre></td></tr></table></figure>
        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/06/14/SpringBoot配置视图/" data-id="cizk115ej001hjj8z6umohoi8" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/06/14/SpringBoot配置视图/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/06/14/SpringBoot配置视图/">评论</a>
    

        </footer>
    </div>
    
</article>



    <article id="Layout-SpringBoot创建maven多模块项目" class="article article-type-Layout" itemscope itemprop="blogPost">
    <div class="article-inner">
        
        
            <header class="article-header">
                
    
        <h1 itemprop="name">
            <a class="article-title" href="/2016/05/21/SpringBoot创建maven多模块项目/">SpringBoot创建maven多模块项目</a>
        </h1>
    

                
                    <div class="article-meta">
                        
    <div class="article-date">
        <i class="fa fa-calendar"></i>
        <a href="/2016/05/21/SpringBoot创建maven多模块项目/">
            <time datetime="2016-05-20T16:00:00.000Z" itemprop="datePublished">2016-05-21</time>
        </a>
    </div>


                        
    <div class="article-category">
    	<i class="fa fa-folder"></i>
        <a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a>
    </div>

                        
    <div class="article-tag">
        <i class="fa fa-tag"></i>
        <a class="tag-link" href="/tags/Maven/">Maven</a>
    </div>

                    </div>
                
            </header>
        
        
        <div class="article-entry" itemprop="articleBody">
        
            
            <h1 id="SpringBoot创建maven多模块项目-实战"><a href="#SpringBoot创建maven多模块项目-实战" class="headerlink" title="SpringBoot创建maven多模块项目(实战)"></a>SpringBoot创建maven多模块项目(实战)</h1><blockquote>
<p>工作中一直都是一个人奋战一人一个项目，使用maven管理，看这个也挺好，但是总感觉没有充分发挥maven的功能，于是研究了一下这个，网上关于这个的文章很多，虽然不是很好，但我从中收获了很多，在这集百家所长，写一份实战记录，大家跟着我一块做吧！</p>
<blockquote>
<p>声明：构建多模块不是最难的，难点是如果把多模块打包成一个执行jar。<br>SpringBoot官方推崇的是富jar，也就是jar文件启动项目，所以如果在这里打war包我不具体介绍，如果需要的朋友可以给我留言，我回复。</p>
<p>建议clone项目后，在看教程（有不足的地方希望大家保函，指出来，我们一起学习改进）</p>
<p>github：<a href="https://github.com/lxchinesszz/multi-boluome.git" target="_blank" rel="external">https://github.com/lxchinesszz/multi-boluome.git</a></p>
</blockquote>
</blockquote>
<h2 id="构建工程"><a href="#构建工程" class="headerlink" title="构建工程"></a>构建工程</h2><ul>
<li><p>1.首先第一步，在github上创建一个公共项目项目名 multi-boluome</p>
<p>  <img src="https://raw.githubusercontent.com/lxchinesszz/multi-boluome/master/web/src/main/resources/static/image/1.%E5%88%9B%E5%BB%BA%E4%BB%93%E7%AE%A1.png" alt=""></p>
</li>
<li><p>2.把仓库同步到本地，使用Intellij idea打开，把普通项目转换为maven项目【右键：Add Frameworks Support】</p>
<p>  <img src="https://raw.githubusercontent.com/lxchinesszz/multi-boluome/master/web/src/main/resources/static/image/2.%E5%91%BD%E4%BB%A4%E8%A1%8C%E4%B8%AD%E5%85%8B%E9%9A%86%E9%A1%B9%E7%9B%AE.png" alt=""></p>
<p>  <img src="https://raw.githubusercontent.com/lxchinesszz/multi-boluome/master/web/src/main/resources/static/image/3.%E8%BD%AC%E6%8D%A2%E4%B8%BAMaven%E9%A1%B9%E7%9B%AE.png" alt="转换为maven项目"></p>
</li>
<li><p>3.删除除了pom文件之外的文件也就是src删除</p>
<p>   <img src="https://raw.githubusercontent.com/lxchinesszz/multi-boluome/master/web/src/main/resources/static/image/4.%E5%89%8D%E7%9B%AE%E5%BD%95.png" alt="删除前"></p>
</li>
<li><p>4.然后新建File-&gt;New-&gt;module以此创建（此时会看到pom文件的变化）</p>
<ul>
<li>web</li>
<li>dao</li>
<li>domain</li>
<li><p>service</p>
<p><img src="https://raw.githubusercontent.com/lxchinesszz/multi-boluome/master/web/src/main/resources/static/image/5.%E5%90%8E%E7%9B%AE%E5%BD%95.png" alt=""></p>
</li>
</ul>
</li>
</ul>
<p>==提示：一定要把外面的pom文件中的<packaging>pom</packaging>==</p>
<ul>
<li>5.引入SpringBoot依赖 这个我在外面写的（这个根据个人）</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div><div class="line">26</div><div class="line">27</div><div class="line">28</div><div class="line">29</div><div class="line">30</div><div class="line">31</div><div class="line">32</div><div class="line">33</div><div class="line">34</div><div class="line">35</div><div class="line">36</div><div class="line">37</div><div class="line">38</div><div class="line">39</div><div class="line">40</div><div class="line">41</div><div class="line">42</div><div class="line">43</div><div class="line">44</div><div class="line">45</div><div class="line">46</div><div class="line">47</div><div class="line">48</div><div class="line">49</div><div class="line">50</div><div class="line">51</div><div class="line">52</div><div class="line">53</div><div class="line">54</div><div class="line">55</div><div class="line">56</div><div class="line">57</div><div class="line">58</div><div class="line">59</div><div class="line">60</div><div class="line">61</div><div class="line">62</div><div class="line">63</div><div class="line">64</div><div class="line">65</div><div class="line">66</div><div class="line">67</div><div class="line">68</div><div class="line">69</div><div class="line">70</div><div class="line">71</div><div class="line">72</div><div class="line">73</div><div class="line">74</div><div class="line">75</div><div class="line">76</div><div class="line">77</div><div class="line">78</div><div class="line">79</div><div class="line">80</div><div class="line">81</div><div class="line">82</div><div class="line">83</div><div class="line">84</div><div class="line">85</div><div class="line">86</div><div class="line">87</div><div class="line">88</div><div class="line">89</div><div class="line">90</div><div class="line">91</div><div class="line">92</div><div class="line">93</div><div class="line">94</div><div class="line">95</div><div class="line">96</div><div class="line">97</div><div class="line">98</div><div class="line">99</div><div class="line">100</div><div class="line">101</div><div class="line">102</div><div class="line">103</div><div class="line">104</div><div class="line">105</div><div class="line">106</div><div class="line">107</div><div class="line">108</div><div class="line">109</div><div class="line">110</div><div class="line">111</div></pre></td><td class="code"><pre><div class="line">	外面的pom文件内容</div><div class="line">	&lt;?xml version=&quot;1.0&quot; encoding=&quot;UTF-8&quot;?&gt;</div><div class="line">&lt;project xmlns=&quot;http://maven.apache.org/POM/4.0.0&quot;</div><div class="line">         xmlns:xsi=&quot;http://www.w3.org/2001/XMLSchema-instance&quot;</div><div class="line">         xsi:schemaLocation=&quot;http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd&quot;&gt;</div><div class="line"></div><div class="line">    &lt;modelVersion&gt;4.0.0&lt;/modelVersion&gt;</div><div class="line">    &lt;groupId&gt;blm.server&lt;/groupId&gt;</div><div class="line">    &lt;artifactId&gt;multi-boluome&lt;/artifactId&gt;</div><div class="line">    &lt;packaging&gt;pom&lt;/packaging&gt;</div><div class="line">    &lt;version&gt;1.0-SNAPSHOT&lt;/version&gt;</div><div class="line"></div><div class="line">    &lt;modules&gt;</div><div class="line">        &lt;module&gt;web&lt;/module&gt;</div><div class="line">        &lt;module&gt;service&lt;/module&gt;</div><div class="line">        &lt;module&gt;dao&lt;/module&gt;</div><div class="line">        &lt;module&gt;domain&lt;/module&gt;</div><div class="line">    &lt;/modules&gt;</div><div class="line"></div><div class="line">    &lt;parent&gt;</div><div class="line">        &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">        &lt;artifactId&gt;spring-boot-starter-parent&lt;/artifactId&gt;</div><div class="line">        &lt;version&gt;1.4.3.RELEASE&lt;/version&gt;</div><div class="line">        &lt;relativePath/&gt; &lt;!-- lookup parent from repository --&gt;</div><div class="line">    &lt;/parent&gt;</div><div class="line"></div><div class="line">    &lt;properties&gt;</div><div class="line">        &lt;project.build.sourceEncoding&gt;UTF-8&lt;/project.build.sourceEncoding&gt;</div><div class="line">        &lt;project.reporting.outputEncoding&gt;UTF-8&lt;/project.reporting.outputEncoding&gt;</div><div class="line">        &lt;java.version&gt;1.8&lt;/java.version&gt;</div><div class="line">        &lt;kotlin.version&gt;1.0.6&lt;/kotlin.version&gt;</div><div class="line">    &lt;/properties&gt;</div><div class="line"></div><div class="line">    &lt;dependencies&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-starter-aop&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-starter-data-mongodb&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-starter-data-redis&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-starter-freemarker&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-starter-web&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line"></div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-starter-test&lt;/artifactId&gt;</div><div class="line">            &lt;scope&gt;test&lt;/scope&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;junit&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;junit&lt;/artifactId&gt;</div><div class="line">            &lt;version&gt;4.12&lt;/version&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;!--引入mock框架--&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.mockito&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;mockito-core&lt;/artifactId&gt;</div><div class="line">            &lt;version&gt;1.10.19&lt;/version&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">        &lt;!--rabbitmq--&gt;</div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-starter-amqp&lt;/artifactId&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line"></div><div class="line">        &lt;dependency&gt;</div><div class="line">            &lt;groupId&gt;com.google.code.gson&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;gson&lt;/artifactId&gt;</div><div class="line">            &lt;version&gt;2.2.4&lt;/version&gt;</div><div class="line">        &lt;/dependency&gt;</div><div class="line">    &lt;/dependencies&gt;</div><div class="line"></div><div class="line">    &lt;build&gt;</div><div class="line">        &lt;plugins&gt;</div><div class="line">            &lt;plugin&gt;</div><div class="line">                &lt;!-- The plugin rewrites your manifest --&gt;</div><div class="line">                &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">                &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;</div><div class="line">                &lt;version&gt;1.3.0.RELEASE&lt;/version&gt;</div><div class="line">                &lt;configuration&gt;&lt;!-- 指定该Main Class为全局的唯一入口 --&gt;</div><div class="line">                    &lt;mainClass&gt;iflyer.IflyerApplication&lt;/mainClass&gt;</div><div class="line">                    &lt;layout&gt;ZIP&lt;/layout&gt;</div><div class="line">                &lt;/configuration&gt;</div><div class="line">                &lt;executions&gt;</div><div class="line">                    &lt;execution&gt;</div><div class="line">                        &lt;goals&gt;</div><div class="line">                            &lt;goal&gt;repackage&lt;/goal&gt;&lt;!--可以把依赖的包都打包到生成的Jar包中--&gt;</div><div class="line">                        &lt;/goals&gt;</div><div class="line">                        &lt;!--可以生成不含依赖包的不可执行Jar包--&gt;</div><div class="line">                        &lt;!-- configuration&gt;</div><div class="line">                          &lt;classifier&gt;exec&lt;/classifier&gt;</div><div class="line">                        &lt;/configuration&gt; --&gt;</div><div class="line">                    &lt;/execution&gt;</div><div class="line">                &lt;/executions&gt;</div><div class="line">            &lt;/plugin&gt;</div><div class="line">        &lt;/plugins&gt;</div><div class="line">    &lt;/build&gt;</div><div class="line"></div><div class="line">&lt;/project&gt;</div></pre></td></tr></table></figure>
<ul>
<li><p>6.开始编写domain层（这里我用mongodb数据库）</p>
</li>
<li><p>7.dao层我要用到数据库，所以在resource中添加配置信息</p>
</li>
<li><p>8.service层中我有用到freemarker的模板引擎，所以添加配置信息</p>
</li>
<li><p>9.web层编写启动类，main方法，main方法要放到目录外层，根据约定哦！</p>
</li>
<li><p>10.每个层及都有自己的依赖</p>
</li>
</ul>
<pre><code><figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div></pre></td><td class="code"><pre><div class="line">eg：</div><div class="line">    dao层依赖domain</div><div class="line">    service依赖dao和domain</div><div class="line">    web层依赖service、dao、domain</div><div class="line">这个关系层次一定要告诉，编辑器，如下设置</div><div class="line">    右键：Open Module Settings打开</div></pre></td></tr></table></figure>



idea修改依赖

 ![](https://raw.githubusercontent.com/lxchinesszz/multi-boluome/master/web/src/main/resources/static/image/6.web%E5%B1%82%E4%BE%9D%E8%B5%963%E4%B8%AA.png)
</code></pre><ul>
<li>11.run一下启动类吧！工程可以启动了</li>
</ul>
<blockquote>
<p>如果出现一下错误<br>Error:java: Annotation processing is not supported for module cycles. Please ensure that all modules<br>说明依赖关系错了，继续看第10步骤吧。</p>
</blockquote>
<h2 id="打包发布jar文件"><a href="#打包发布jar文件" class="headerlink" title="打包发布jar文件"></a>打包发布jar文件</h2><ul>
<li><p>1.在启动类中修改pom文件(也就是web层的)</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div></pre></td><td class="code"><pre><div class="line">&lt;build&gt;</div><div class="line">    &lt;!-- 为jar包取名 --&gt;</div><div class="line">    &lt;finalName&gt;blm-start&lt;/finalName&gt;</div><div class="line">    &lt;plugins&gt;</div><div class="line">        &lt;plugin&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;</div><div class="line">            &lt;version&gt;1.3.0.RELEASE&lt;/version&gt;</div><div class="line">        &lt;/plugin&gt;</div><div class="line">    &lt;/plugins&gt;</div><div class="line">&lt;/build&gt;</div></pre></td></tr></table></figure>
</li>
</ul>
<ul>
<li><p>2.在外层pom中构建插件</p>
  <figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div><div class="line">17</div><div class="line">18</div><div class="line">19</div><div class="line">20</div><div class="line">21</div><div class="line">22</div><div class="line">23</div><div class="line">24</div><div class="line">25</div></pre></td><td class="code"><pre><div class="line">&lt;build&gt;</div><div class="line">    &lt;plugins&gt;</div><div class="line">        &lt;plugin&gt;</div><div class="line">            &lt;!-- The plugin rewrites your manifest --&gt;</div><div class="line">            &lt;groupId&gt;org.springframework.boot&lt;/groupId&gt;</div><div class="line">            &lt;artifactId&gt;spring-boot-maven-plugin&lt;/artifactId&gt;</div><div class="line">            &lt;version&gt;1.3.0.RELEASE&lt;/version&gt;</div><div class="line">            &lt;configuration&gt;&lt;!-- 指定该Main Class为全局的唯一入口 --&gt;</div><div class="line">                &lt;mainClass&gt;com.Application&lt;/mainClass&gt;</div><div class="line">                &lt;layout&gt;ZIP&lt;/layout&gt;</div><div class="line">            &lt;/configuration&gt;</div><div class="line">            &lt;executions&gt;</div><div class="line">                &lt;execution&gt;</div><div class="line">                    &lt;goals&gt;</div><div class="line">                        &lt;goal&gt;repackage&lt;/goal&gt;&lt;!--可以把依赖的包都打包到生成的Jar包中--&gt;</div><div class="line">                    &lt;/goals&gt;</div><div class="line">                    &lt;!--可以生成不含依赖包的不可执行Jar包--&gt;</div><div class="line">                    &lt;!-- configuration&gt;</div><div class="line">                      &lt;classifier&gt;exec&lt;/classifier&gt;</div><div class="line">                    &lt;/configuration&gt; --&gt;</div><div class="line">                &lt;/execution&gt;</div><div class="line">            &lt;/executions&gt;</div><div class="line">        &lt;/plugin&gt;</div><div class="line">    &lt;/plugins&gt;</div><div class="line">&lt;/build&gt;</div></pre></td></tr></table></figure>
</li>
</ul>
<ul>
<li>3.打包吧，mvn package —Dmaven.test.skip=true 跳过测试</li>
</ul>
<figure class="highlight plain"><table><tr><td class="gutter"><pre><div class="line">1</div><div class="line">2</div><div class="line">3</div><div class="line">4</div><div class="line">5</div><div class="line">6</div><div class="line">7</div><div class="line">8</div><div class="line">9</div><div class="line">10</div><div class="line">11</div><div class="line">12</div><div class="line">13</div><div class="line">14</div><div class="line">15</div><div class="line">16</div></pre></td><td class="code"><pre><div class="line">[INFO] multi-boluome ...................................... SUCCESS [  1.707 s]</div><div class="line">[INFO] domain ............................................. SUCCESS [  2.463 s]</div><div class="line">[INFO] dao ................................................ SUCCESS [  0.592 s]</div><div class="line">[INFO] service ............................................ SUCCESS [  0.606 s]</div><div class="line">[INFO] web ................................................ SUCCESS [  1.135 s]</div><div class="line">[INFO] ------------------------------------------------------------------------</div><div class="line">[INFO] BUILD SUCCESS</div><div class="line">[INFO] ------------------------------------------------------------------------</div><div class="line">[INFO] Total time: 7.290 s</div><div class="line">[INFO] Finished at: 2017-01-20T17:05:14+08:00</div><div class="line">[INFO] Final Memory: 42M/265M</div><div class="line">[INFO] ------------------------------------------------------------------------</div><div class="line">KK-MINI:multi-boluome liuxin$ </div><div class="line"></div><div class="line">INFO] Building jar: /Users/liuxin/git/模仿项目/multi-boluome/web/target/blm-start.jar</div><div class="line">构建文件在这个目录下</div></pre></td></tr></table></figure>
<h1 id="very-Good！开始飞吧"><a href="#very-Good！开始飞吧" class="headerlink" title="very Good！开始飞吧"></a>very Good！开始飞吧</h1><p>==提醒：所有模块里面的父节点都是一样的哦，不然会报错 unknow.version==</p>
<blockquote>
<p>WARNING] ‘parent.relativePath’ of POM blm.server:domain:[unknown-version] 类似</p>
</blockquote>

        
        </div>
        <footer class="article-footer">
            <div class="share-container">



</div>

    <a data-url="http://yoursite.com/2016/05/21/SpringBoot创建maven多模块项目/" data-id="cizk115dr0010jj8zjouxkuva" class="article-share-link"><i class="fa fa-share"></i>分享到</a>
<script>
    (function ($) {
        // Prevent duplicate binding
        if (typeof(__SHARE_BUTTON_BINDED__) === 'undefined' || !__SHARE_BUTTON_BINDED__) {
            __SHARE_BUTTON_BINDED__ = true;
        } else {
            return;
        }
        $('body').on('click', function() {
            $('.article-share-box.on').removeClass('on');
        }).on('click', '.article-share-link', function(e) {
            e.stopPropagation();

            var $this = $(this),
                url = $this.attr('data-url'),
                encodedUrl = encodeURIComponent(url),
                id = 'article-share-box-' + $this.attr('data-id'),
                offset = $this.offset(),
                box;

            if ($('#' + id).length) {
                box = $('#' + id);

                if (box.hasClass('on')){
                    box.removeClass('on');
                    return;
                }
            } else {
                var html = [
                    '<div id="' + id + '" class="article-share-box">',
                        '<input class="article-share-input" value="' + url + '">',
                        '<div class="article-share-links">',
                            '<a href="https://twitter.com/intent/tweet?url=' + encodedUrl + '" class="fa fa-twitter article-share-twitter" target="_blank" title="Twitter"></a>',
                            '<a href="https://www.facebook.com/sharer.php?u=' + encodedUrl + '" class="fa fa-facebook article-share-facebook" target="_blank" title="Facebook"></a>',
                            '<a href="http://pinterest.com/pin/create/button/?url=' + encodedUrl + '" class="fa fa-pinterest article-share-pinterest" target="_blank" title="Pinterest"></a>',
                            '<a href="https://plus.google.com/share?url=' + encodedUrl + '" class="fa fa-google article-share-google" target="_blank" title="Google+"></a>',
                        '</div>',
                    '</div>'
                ].join('');

              box = $(html);

              $('body').append(box);
            }

            $('.article-share-box.on').hide();

            box.css({
                top: offset.top + 25,
                left: offset.left
            }).addClass('on');

        }).on('click', '.article-share-box', function (e) {
            e.stopPropagation();
        }).on('click', '.article-share-box-input', function () {
            $(this).select();
        }).on('click', '.article-share-box-link', function (e) {
            e.preventDefault();
            e.stopPropagation();

            window.open(this.href, 'article-share-box-window-' + Date.now(), 'width=500,height=450');
        });
    })(jQuery);
</script>

            
    
        <a href="http://yoursite.com/2016/05/21/SpringBoot创建maven多模块项目/#comments" class="article-comment-link ds-thread-count" data-thread-key="http://yoursite.com/2016/05/21/SpringBoot创建maven多模块项目/">评论</a>
    

        </footer>
    </div>
    
</article>



    <nav id="page-nav">
        <a class="extend prev" rel="prev" href="/">&laquo; 上一页</a><a class="page-number" href="/">1</a><span class="page-number current">2</span><a class="page-number" href="/page/3/">3</a><a class="extend next" rel="next" href="/page/3/">下一页 &raquo;</a>
    </nav>
</section>
            
                <aside id="sidebar">
   
        
    <div class="widget-wrap">
        <h3 class="widget-title">最新文章</h3>
        <div class="widget">
            <ul id="recent-post" class="">
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/2017/05/17/CPU-bound(计算密集型) 和IO bound(IO密集型)、进程vs线程/" class="thumbnail">
    
    
        <span class="thumbnail-image thumbnail-none"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/categories/服务器/">服务器</a></p>
                            <p class="item-title"><a href="/2017/05/17/CPU-bound(计算密集型) 和IO bound(IO密集型)、进程vs线程/" class="title">CPU-bound(计算密集型) 和IO bound(IO密集型)、进程vs线程</a></p>
                            <p class="item-date"><time datetime="2017-05-16T16:00:00.000Z" itemprop="datePublished">2017-05-17</time></p>
                        </div>
                    </li>
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/2017/04/27/Spring Boot中使用@Async实现异步调用/" class="thumbnail">
    
    
        <span class="thumbnail-image thumbnail-none"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a></p>
                            <p class="item-title"><a href="/2017/04/27/Spring Boot中使用@Async实现异步调用/" class="title">Spring Boot中使用@Async实现异步调用</a></p>
                            <p class="item-date"><time datetime="2017-04-26T16:00:00.000Z" itemprop="datePublished">2017-04-27</time></p>
                        </div>
                    </li>
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/2017/01/28/线程数究竟设多少合理/" class="thumbnail">
    
    
        <span class="thumbnail-image thumbnail-none"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/categories/服务器/">服务器</a></p>
                            <p class="item-title"><a href="/2017/01/28/线程数究竟设多少合理/" class="title">线程数究竟设多少合理</a></p>
                            <p class="item-date"><time datetime="2017-01-27T16:00:00.000Z" itemprop="datePublished">2017-01-28</time></p>
                        </div>
                    </li>
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/2017/01/27/浅谈分布式与集群(未完待续)/" class="thumbnail">
    
    
        <span class="thumbnail-image thumbnail-none"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/categories/系统架构/">系统架构</a></p>
                            <p class="item-title"><a href="/2017/01/27/浅谈分布式与集群(未完待续)/" class="title">浅谈分布式与集群(未完待续)</a></p>
                            <p class="item-date"><time datetime="2017-01-26T16:00:00.000Z" itemprop="datePublished">2017-01-27</time></p>
                        </div>
                    </li>
                
                    <li>
                        
                        <div class="item-thumbnail">
                            <a href="/2017/01/11/Spring Cloud系列五 之 服务网关/" class="thumbnail">
    
    
        <span class="thumbnail-image thumbnail-none"></span>
    
</a>

                        </div>
                        
                        <div class="item-inner">
                            <p class="item-category"><a class="article-category-link" href="/categories/Spring-Cloud/">Spring Cloud</a></p>
                            <p class="item-title"><a href="/2017/01/11/Spring Cloud系列五 之 服务网关/" class="title">Spring Cloud系列五 之 服务网关</a></p>
                            <p class="item-date"><time datetime="2017-01-10T16:00:00.000Z" itemprop="datePublished">2017-01-11</time></p>
                        </div>
                    </li>
                
            </ul>
        </div>
    </div>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title">分类</h3>
        <div class="widget">
            <ul class="category-list"><li class="category-list-item"><a class="category-list-link" href="/categories/Java命名规范/">Java命名规范</a><span class="category-list-count">1</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Spring-Boot实战/">Spring Boot实战</a><span class="category-list-count">13</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/Spring-Cloud/">Spring Cloud</a><span class="category-list-count">6</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/服务器/">服务器</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/服务器搭建/">服务器搭建</a><span class="category-list-count">2</span></li><li class="category-list-item"><a class="category-list-link" href="/categories/系统架构/">系统架构</a><span class="category-list-count">1</span></li></ul>
        </div>
    </div>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title">归档</h3>
        <div class="widget">
            <ul class="archive-list"><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/05/">五月 2017</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/04/">四月 2017</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2017/01/">一月 2017</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/12/">十二月 2016</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/11/">十一月 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/10/">十月 2016</a><span class="archive-list-count">1</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/08/">八月 2016</a><span class="archive-list-count">5</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/07/">七月 2016</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/06/">六月 2016</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/05/">五月 2016</a><span class="archive-list-count">2</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2016/01/">一月 2016</a><span class="archive-list-count">3</span></li><li class="archive-list-item"><a class="archive-list-link" href="/archives/2015/01/">一月 2015</a><span class="archive-list-count">1</span></li></ul>
        </div>
    </div>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title">标签</h3>
        <div class="widget">
            <ul class="tag-list"><li class="tag-list-item"><a class="tag-list-link" href="/tags/Java命名规范/">Java命名规范</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Maven/">Maven</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Spring-Boot中使用-Async实现异步调用/">Spring Boot中使用@Async实现异步调用</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Spring-Boot注解/">Spring Boot注解</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Spring-Cloud/">Spring Cloud</a><span class="tag-list-count">6</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SpringBoot原生定时任务解析/">SpringBoot原生定时任务解析</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SpringBoot在启动类配置端口号/">SpringBoot在启动类配置端口号</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SpringBoot拦截器/">SpringBoot拦截器</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/SpringBoot配置视图/">SpringBoot配置视图</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/Spring整合Quartz2-1-1/">Spring整合Quartz2.1.1</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/优化方案/">优化方案</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/分布式与集群/">分布式与集群</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/动态读取任务执行/">动态读取任务执行</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/启动环境/">启动环境</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/整合定时任务/">整合定时任务</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/服务器/">服务器</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/服务器搭建/">服务器搭建</a><span class="tag-list-count">2</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/计算/">计算</a><span class="tag-list-count">1</span></li><li class="tag-list-item"><a class="tag-list-link" href="/tags/配置文件加载/">配置文件加载</a><span class="tag-list-count">1</span></li></ul>
        </div>
    </div>

    
        
    <div class="widget-wrap">
        <h3 class="widget-title">标签云</h3>
        <div class="widget tagcloud">
            <a href="/tags/Java命名规范/" style="font-size: 10px;">Java命名规范</a> <a href="/tags/Maven/" style="font-size: 10px;">Maven</a> <a href="/tags/Spring-Boot中使用-Async实现异步调用/" style="font-size: 10px;">Spring Boot中使用@Async实现异步调用</a> <a href="/tags/Spring-Boot注解/" style="font-size: 10px;">Spring Boot注解</a> <a href="/tags/Spring-Cloud/" style="font-size: 20px;">Spring Cloud</a> <a href="/tags/SpringBoot原生定时任务解析/" style="font-size: 10px;">SpringBoot原生定时任务解析</a> <a href="/tags/SpringBoot在启动类配置端口号/" style="font-size: 10px;">SpringBoot在启动类配置端口号</a> <a href="/tags/SpringBoot拦截器/" style="font-size: 10px;">SpringBoot拦截器</a> <a href="/tags/SpringBoot配置视图/" style="font-size: 10px;">SpringBoot配置视图</a> <a href="/tags/Spring整合Quartz2-1-1/" style="font-size: 10px;">Spring整合Quartz2.1.1</a> <a href="/tags/优化方案/" style="font-size: 10px;">优化方案</a> <a href="/tags/分布式与集群/" style="font-size: 10px;">分布式与集群</a> <a href="/tags/动态读取任务执行/" style="font-size: 10px;">动态读取任务执行</a> <a href="/tags/启动环境/" style="font-size: 10px;">启动环境</a> <a href="/tags/整合定时任务/" style="font-size: 10px;">整合定时任务</a> <a href="/tags/服务器/" style="font-size: 10px;">服务器</a> <a href="/tags/服务器搭建/" style="font-size: 15px;">服务器搭建</a> <a href="/tags/计算/" style="font-size: 10px;">计算</a> <a href="/tags/配置文件加载/" style="font-size: 10px;">配置文件加载</a>
        </div>
    </div>

    
        
    <div class="widget-wrap widget-list">
        <h3 class="widget-title">链接</h3>
        <div class="widget">
            <ul>
                
                    <li>
                        <a href="http://www.jianshu.com/u/e210c8fa704f">简书</a>
                    </li>
                
                    <li>
                        <a href="http://blog.csdn.net/message_lx/article/details/56674087">CSDN</a>
                    </li>
                
                    <li>
                        <a href="https://www.zhihu.com/people/chinesszz/activities">知乎</a>
                    </li>
                
                    <li>
                        <a href="https://my.oschina.net/chinesszz/blog">开源中国</a>
                    </li>
                
                    <li>
                        <a href="https://lxchinesszz.github.io/">GITHUB博客</a>
                    </li>
                
            </ul>
        </div>
    </div>


    
    <div id="toTop" class="fa fa-angle-up"></div>
</aside>
            
        </div>
        <footer id="footer">
    <div class="outer">
        <div id="footer-info" class="inner">
            &copy; 2017<br>
            <a href="http://www.jianshu.com/u/e210c8fa704f" target="_blank">简书</a>. by <a href="https://github.com/lxchinesszz">Liuxin</a>
        </div>
    </div>
</footer>
        
    
    <script type="text/javascript">
    var duoshuoQuery = {short_name:'lxchinesszz'};
    (function() {
    var ds = document.createElement('script');
    ds.type = 'text/javascript';ds.async = true;
    ds.src = (document.location.protocol == 'https:' ? 'https:' : 'http:') + '//static.duoshuo.com/embed.js';
    ds.charset = 'UTF-8';
    (document.getElementsByTagName('head')[0]
    || document.getElementsByTagName('body')[0]).appendChild(ds);
    })();
    </script>



    
        <script src="/libs/lightgallery/js/lightgallery.min.js"></script>
        <script src="/libs/lightgallery/js/lg-thumbnail.min.js"></script>
        <script src="/libs/lightgallery/js/lg-pager.min.js"></script>
        <script src="/libs/lightgallery/js/lg-autoplay.min.js"></script>
        <script src="/libs/lightgallery/js/lg-fullscreen.min.js"></script>
        <script src="/libs/lightgallery/js/lg-zoom.min.js"></script>
        <script src="/libs/lightgallery/js/lg-hash.min.js"></script>
        <script src="/libs/lightgallery/js/lg-share.min.js"></script>
        <script src="/libs/lightgallery/js/lg-video.min.js"></script>
    
    
        <script src="/libs/justified-gallery/jquery.justifiedGallery.min.js"></script>
    



<!-- Custom Scripts -->
<script src="/js/main.js"></script>

    </div>
</body>
</html>